package com.atm.atmsys.Mapper.AdminMapper;


import com.atm.atmsys.dto.AdminPageQueryDTO;
import com.atm.atmsys.entity.AdminInfo;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface AdminMapper {

    //银行管理员登录（根据管理员的name和password来查管理员信息）
    @Select("select * from atm_database.admin_info where admin_name=#{adminName} and admin_password=#{adminPassword}")
    AdminInfo getByAdminNameAndPassword(AdminInfo adminInfo);


    //新增管理员信息
    @Insert("insert into atm_database.admin_info (admin_name,admin_password,create_time,update_time,create_admin,update_admin) " +
            "values (#{adminName},#{adminPassword},#{createTime},#{updateTime},#{createAdmin},#{updateAdmin})")
    void addAdmin(AdminInfo adminInfo);


    //分页查询管理员信息
    Page<AdminInfo> pageQuery(AdminPageQueryDTO adminPageQueryDTO);

    //根据管理员id查询管理员信息
    @Select("select * from atm_database.admin_info where admin_id=#{id}")
    AdminInfo getAdminById(Integer id);


    //编辑管理员信息
    void updateAdmin(AdminInfo adminInfo);

    //删除管理员信息
    @Select("delete from atm_database.admin_info where admin_id=#{id}")
    void deleteAdmin(Integer id);

    @Select("select admin_id from atm_database.admin_info where admin_name=#{name}")
    Integer getIdbyName(String name);
}
